Database reference guide

HOME

Persistent Expressions

Expressions can also be created in the SELECT part of an NSQL statement. At this point they can be given a name that can then be used in the WHERE part of the same statement:

SELECT EXPR{ LEFT(Surname,1) } AS [ FirstChar]

FROM Customer

WHERE FirstChar in (“A”,”E”,”I”,”O”,”U”);

This creates a new column called FirstChar, which is the first character of each customer's surname. The statement then goes on to use this column in the WHERE clause selecting all those customers whose surname starts with a vowel.

Note: Once a new column has been created this way, it will remain in the system until it is deleted. Therefore it can be used again in subsequent queries without re-declaration. In fact, attempting to re-declare it will cause an error.
  Online & Instructor-Led Courses | Training Videos | Webinar Recordings
© Alterian. All Rights Reserved. | Privacy Policy | Legal Notice